---
title: "Figure 2"
output: 
---

# Figure 2

# Who's to Blame? Postconflict Violence and Public Attitudes Towards Peace Agreements
# Wyer, Frank. 

#clear environment
```{r clear environment}
rm(list = ls())
```

# uncomment and set working directory to replication archive
# setwd("~/blame_replication")

# Uncomment to install packages if necessary
# install.packages("tidyverse")
# install.packages("estimatr")

#load packages
```{r}
library(tidyverse)
library(estimatr)
```

#read in data
```{r}
survey_clean <- read.csv("survey_clean.csv")
```

#estimate main treatment effects on outcomes of interest using lin estimator
```{r estimate main treatment effects}

#eln outcome 
eln_shortmodel_95 <- lm_lin(formula = eln_scale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean, alpha = .05)
eln_shortmodel_90 <- lm_lin(formula = eln_scale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean, alpha = .1)

#farc dissidents outcome
dissident_shortmodel_95 <- lm_lin(formula = dissident_scale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean, alpha = .05)
dissident_shortmodel_90 <- lm_lin(formula = dissident_scale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean, alpha = .1)

#peace accords outcome
accords_shortmodel_95 <- lm_lin(formula = accords_scale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean, alpha = .05)
accords_shortmodel_90 <- lm_lin(formula = accords_scale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean, alpha = .1)

#peace index outcome
index_shortmodel_95 <- lm_lin(formula = outcomes_zscale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean, alpha = .05)
index_shortmodel_90 <- lm_lin(formula = outcomes_zscale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + farc_presence + homratediff + factor(regionname), se_type = "HC2", data = survey_clean, alpha = .1)
```

#lin estimator centers covariates and interacts them with treatment variable
#recreate lin estimator manually to recover interactions for specific covariates
#1 center all covariates
#2 interact un-centered version of covariate of interest with treatment
#3 interact centered version of all other covariates with treatment

#centering covariates for manual lin estimation strategy
```{r center covariates for lin estimation}
survey_clean$age_c <- c(scale(survey_clean$Q15, center = TRUE, scale = FALSE))
survey_clean$ideology_c <- c(scale(survey_clean$Q25, center = TRUE, scale = FALSE))
survey_clean$urban_c <- c(scale(survey_clean$urbandummy, center = TRUE, scale = FALSE))
survey_clean$engage_c <- c(scale(survey_clean$engage_zscale, center = TRUE, scale = FALSE))
survey_clean$farc_c <- c(scale(survey_clean$farc_presence, center = TRUE, scale = FALSE))
survey_clean$homratediff_c <- c(scale(survey_clean$homratediff, center = TRUE, scale = FALSE))
survey_clean$homrate100k_c <- c(scale(survey_clean$homrate100k, center = TRUE, scale = FALSE))

survey_clean <- survey_clean %>% 
mutate(
  southdummy = ifelse(regionname == "Sur", 1, 0),
  caribdummy = ifelse(regionname == "Caribe", 1, 0),
  nwdummy = ifelse(regionname == "Noroccidental", 1, 0),
  nedummy = ifelse(regionname == "Nororiental", 1, 0),
  centraldummy = ifelse(regionname == "Central", 1, 0),
  westdummy = ifelse(regionname == "Occidental", 1, 0),
  eastdummy = ifelse(regionname == "Oriental", 1, 0)
)

# carribean region is omitted category

survey_clean$southdummy_c <- c(scale(survey_clean$southdummy, center = TRUE, scale = FALSE))
survey_clean$caribdummy_c <- c(scale(survey_clean$caribdummy, center = TRUE, scale = FALSE))
survey_clean$nwdummy_c <- c(scale(survey_clean$nwdummy, center = TRUE, scale = FALSE))
survey_clean$nedummy_c <- c(scale(survey_clean$nedummy, center = TRUE, scale = FALSE))
survey_clean$centraldummy_c <- c(scale(survey_clean$centraldummy, center = TRUE, scale = FALSE))
survey_clean$westdummy_c <- c(scale(survey_clean$westdummy, center = TRUE, scale = FALSE))
survey_clean$eastdummy_c <- c(scale(survey_clean$eastdummy, center = TRUE, scale = FALSE))
```

#estimate het effects models with index outcome
```{r farc het effects models: index outcome}
index_farc_95 <- lm_robust(outcomes_zscale ~ treatment*farc_presence + treatment*age_c + treatment*ideology_c + treatment*urban_c + treatment*engage_c + treatment*homratediff_c + treatment*southdummy_c + treatment*nwdummy_c + treatment*nedummy_c + treatment*centraldummy_c + treatment*westdummy_c + treatment*eastdummy_c, data = survey_clean, se_type = "HC2", alpha = .05)

index_farc_90 <- lm_robust(outcomes_zscale ~ treatment*farc_presence + treatment*age_c + treatment*ideology_c + treatment*urban_c + treatment*engage_c + treatment*homratediff_c + treatment*southdummy_c + treatment*nwdummy_c + treatment*nedummy_c + treatment*centraldummy_c + treatment*westdummy_c + treatment*eastdummy_c, data = survey_clean, se_type = "HC2", alpha = .1)

index_farc_95_invert <- lm_robust(outcomes_zscale ~ treatment*factor(farc_presence == 0) + treatment*age_c + treatment*ideology_c + treatment*urban_c + treatment*engage_c + treatment*homratediff_c + treatment*southdummy_c + treatment*nwdummy_c + treatment*nedummy_c + treatment*centraldummy_c + treatment*westdummy_c + treatment*eastdummy_c, data = survey_clean, se_type = "HC2", alpha = .05)

index_farc_90_invert <- lm_robust(outcomes_zscale ~ treatment*factor(farc_presence == 0) + treatment*age_c + treatment*ideology_c + treatment*urban_c + treatment*engage_c + treatment*homratediff_c + treatment*southdummy_c + treatment*nwdummy_c + treatment*nedummy_c + treatment*centraldummy_c + treatment*westdummy_c + treatment*eastdummy_c, data = survey_clean, se_type = "HC2", alpha = .1)
```

#estimate het effects models with ELN outcome
```{r farc het effects models: ELN outcome}
eln_farc_95 <- lm_robust(eln_scale ~ treatment*farc_presence + treatment*age_c + treatment*ideology_c + treatment*urban_c + treatment*engage_c + treatment*homratediff_c + treatment*southdummy_c + treatment*nwdummy_c + treatment*nedummy_c + treatment*centraldummy_c + treatment*westdummy_c + treatment*eastdummy_c, data = survey_clean, se_type = "HC2", alpha = .05)

eln_farc_90 <- lm_robust(eln_scale ~ treatment*farc_presence + treatment*age_c + treatment*ideology_c + treatment*urban_c + treatment*engage_c + treatment*homratediff_c + treatment*southdummy_c + treatment*nwdummy_c + treatment*nedummy_c + treatment*centraldummy_c + treatment*westdummy_c + treatment*eastdummy_c, data = survey_clean, se_type = "HC2", alpha = .1)

eln_farc_95_invert <- lm_robust(eln_scale ~ treatment*factor(farc_presence == 0) + treatment*age_c + treatment*ideology_c + treatment*urban_c + treatment*engage_c + treatment*homratediff_c + treatment*southdummy_c + treatment*nwdummy_c + treatment*nedummy_c + treatment*centraldummy_c + treatment*westdummy_c + treatment*eastdummy_c, data = survey_clean, se_type = "HC2", alpha = .05)

eln_farc_90_invert <- lm_robust(eln_scale ~ treatment*factor(farc_presence == 0) + treatment*age_c + treatment*ideology_c + treatment*urban_c + treatment*engage_c + treatment*homratediff_c + treatment*southdummy_c + treatment*nwdummy_c + treatment*nedummy_c + treatment*centraldummy_c + treatment*westdummy_c + treatment*eastdummy_c, data = survey_clean, se_type = "HC2", alpha = .1)
```

#estimate het effects models with FARC dissidents outcome
```{r farc het effects models: dissidents outcome}
dissidents_farc_95 <- lm_robust(dissident_scale ~ treatment*farc_presence + treatment*age_c + treatment*ideology_c + treatment*urban_c + treatment*engage_c + treatment*homratediff_c + treatment*southdummy_c + treatment*nwdummy_c + treatment*nedummy_c + treatment*centraldummy_c + treatment*westdummy_c + treatment*eastdummy_c, data = survey_clean, se_type = "HC2", alpha = .05)

dissidents_farc_90 <- lm_robust(dissident_scale ~ treatment*farc_presence + treatment*age_c + treatment*ideology_c + treatment*urban_c + treatment*engage_c + treatment*homratediff_c + treatment*southdummy_c + treatment*nwdummy_c + treatment*nedummy_c + treatment*centraldummy_c + treatment*westdummy_c + treatment*eastdummy_c, data = survey_clean, se_type = "HC2", alpha = .1)

dissidents_farc_95_invert <- lm_robust(dissident_scale ~ treatment*factor(farc_presence == 0) + treatment*age_c + treatment*ideology_c + treatment*urban_c + treatment*engage_c + treatment*homratediff_c + treatment*southdummy_c + treatment*nwdummy_c + treatment*nedummy_c + treatment*centraldummy_c + treatment*westdummy_c + treatment*eastdummy_c, data = survey_clean, se_type = "HC2", alpha = .05)

dissidents_farc_90_invert <- lm_robust(dissident_scale ~ treatment*factor(farc_presence == 0) + treatment*age_c + treatment*ideology_c + treatment*urban_c + treatment*engage_c + treatment*homratediff_c + treatment*southdummy_c + treatment*nwdummy_c + treatment*nedummy_c + treatment*centraldummy_c + treatment*westdummy_c + treatment*eastdummy_c, data = survey_clean, se_type = "HC2", alpha = .1)
```

#estimate het effects models with peace accords outcome
```{r farc het effects models: accords outcome}
accords_farc_95 <- lm_robust(accords_scale ~ treatment*farc_presence + treatment*age_c + treatment*ideology_c + treatment*urban_c + treatment*engage_c + treatment*homratediff_c + treatment*southdummy_c + treatment*nwdummy_c + treatment*nedummy_c + treatment*centraldummy_c + treatment*westdummy_c + treatment*eastdummy_c, data = survey_clean, se_type = "HC2", alpha = .05)

accords_farc_90 <- lm_robust(accords_scale ~ treatment*farc_presence + treatment*age_c + treatment*ideology_c + treatment*urban_c + treatment*engage_c + treatment*homratediff_c + treatment*southdummy_c + treatment*nwdummy_c + treatment*nedummy_c + treatment*centraldummy_c + treatment*westdummy_c + treatment*eastdummy_c, data = survey_clean, se_type = "HC2", alpha = .1)

accords_farc_95_invert <- lm_robust(accords_scale ~ treatment*factor(farc_presence == 0) + treatment*age_c + treatment*ideology_c + treatment*urban_c + treatment*engage_c + treatment*homratediff_c + treatment*southdummy_c + treatment*nwdummy_c + treatment*nedummy_c + treatment*centraldummy_c + treatment*westdummy_c + treatment*eastdummy_c, data = survey_clean, se_type = "HC2", alpha = .05)

accords_farc_90_invert <- lm_robust(accords_scale ~ treatment*factor(farc_presence == 0) + treatment*age_c + treatment*ideology_c + treatment*urban_c + treatment*engage_c + treatment*homratediff_c + treatment*southdummy_c + treatment*nwdummy_c + treatment*nedummy_c + treatment*centraldummy_c + treatment*westdummy_c + treatment*eastdummy_c, data = survey_clean, se_type = "HC2", alpha = .1)
```

#extract model coefficients and merge into dataframe
```{r farc het effects dataframe}
farc_het_effects_all <- rbind(
  
#index outcome  
  
data.frame(Treatment = "Rebel Culpability Treatment: Full Sample", Method = "Select Covariates", Conf_Level = "90%", Outcome = "Peace Agreement Attitudes Index*", Estimate = index_shortmodel_90$coefficients['treatmentT2B'], Conf_Low = index_shortmodel_90$conf.low['treatmentT2B'], Conf_High = index_shortmodel_90$conf.high['treatmentT2B']), 
data.frame(Treatment = "Rebel Culpability Treatment: Full Sample", Method = "Select Covariates", Conf_Level = "95%", Outcome = "Peace Agreement Attitudes Index*", Estimate = index_shortmodel_95$coefficients['treatmentT2B'], Conf_Low = index_shortmodel_95$conf.low['treatmentT2B'], Conf_High = index_shortmodel_95$conf.high['treatmentT2B']), 

data.frame(Treatment = "Rebel Culpability Treatment: Non-FARC Zones", Method = "Select Covariates", Conf_Level = "90%", Outcome = "Peace Agreement Attitudes Index*", Estimate = index_farc_90$coefficients['treatmentT2B'], Conf_Low = index_farc_90$conf.low['treatmentT2B'], Conf_High = index_farc_90$conf.high['treatmentT2B']), 
data.frame(Treatment = "Rebel Culpability Treatment: Non-FARC Zones", Method = "Select Covariates", Conf_Level = "95%", Outcome = "Peace Agreement Attitudes Index*", Estimate = index_farc_95$coefficients['treatmentT2B'], Conf_Low = index_farc_95$conf.low['treatmentT2B'], Conf_High = index_farc_95$conf.high['treatmentT2B']), 

data.frame(Treatment = "Rebel Culpability Treatment: FARC Zones", Method = "Select Covariates", Conf_Level = "90%", Outcome = "Peace Agreement Attitudes Index*", Estimate = index_farc_90_invert$coefficients['treatmentT2B'], Conf_Low = index_farc_90_invert$conf.low['treatmentT2B'], Conf_High = index_farc_90_invert$conf.high['treatmentT2B']), 
data.frame(Treatment = "Rebel Culpability Treatment: FARC Zones", Method = "Select Covariates", Conf_Level = "95%", Outcome = "Peace Agreement Attitudes Index*", Estimate = index_farc_95_invert$coefficients['treatmentT2B'], Conf_Low = index_farc_95_invert$conf.low['treatmentT2B'], Conf_High = index_farc_95_invert$conf.high['treatmentT2B']), 

data.frame(Treatment = "Difference", Method = "Select Covariates", Conf_Level = "90%", Outcome = "Peace Agreement Attitudes Index*", Estimate = index_farc_90$coefficients['treatmentT2B:farc_presence'], Conf_Low = index_farc_90$conf.low['treatmentT2B:farc_presence'], Conf_High = index_farc_90$conf.high['treatmentT2B:farc_presence']), 
data.frame(Treatment = "Difference", Method = "Select Covariates", Conf_Level = "95%", Outcome = "Peace Agreement Attitudes Index*", Estimate = index_farc_95$coefficients['treatmentT2B:farc_presence'], Conf_Low = index_farc_95$conf.low['treatmentT2B:farc_presence'], Conf_High = index_farc_95$conf.high['treatmentT2B:farc_presence']), 

#accords outcome  
  
data.frame(Treatment = "Rebel Culpability Treatment: Full Sample", Method = "Select Covariates", Conf_Level = "90%", Outcome = "Confidence in 2016 Peace Agreement", Estimate = accords_shortmodel_90$coefficients['treatmentT2B'], Conf_Low = accords_shortmodel_90$conf.low['treatmentT2B'], Conf_High = accords_shortmodel_90$conf.high['treatmentT2B']), 
data.frame(Treatment = "Rebel Culpability Treatment: Full Sample", Method = "Select Covariates", Conf_Level = "95%", Outcome = "Confidence in 2016 Peace Agreement", Estimate = accords_shortmodel_95$coefficients['treatmentT2B'], Conf_Low = accords_shortmodel_95$conf.low['treatmentT2B'], Conf_High = accords_shortmodel_95$conf.high['treatmentT2B']), 

data.frame(Treatment = "Rebel Culpability Treatment: Non-FARC Zones", Method = "Select Covariates", Conf_Level = "90%", Outcome = "Confidence in 2016 Peace Agreement", Estimate = accords_farc_90$coefficients['treatmentT2B'], Conf_Low = accords_farc_90$conf.low['treatmentT2B'], Conf_High = accords_farc_90$conf.high['treatmentT2B']), 
data.frame(Treatment = "Rebel Culpability Treatment: Non-FARC Zones", Method = "Select Covariates", Conf_Level = "95%", Outcome = "Confidence in 2016 Peace Agreement", Estimate = accords_farc_95$coefficients['treatmentT2B'], Conf_Low = accords_farc_95$conf.low['treatmentT2B'], Conf_High = accords_farc_95$conf.high['treatmentT2B']), 

data.frame(Treatment = "Rebel Culpability Treatment: FARC Zones", Method = "Select Covariates", Conf_Level = "90%", Outcome = "Confidence in 2016 Peace Agreement", Estimate = accords_farc_90_invert$coefficients['treatmentT2B'], Conf_Low = accords_farc_90_invert$conf.low['treatmentT2B'], Conf_High = accords_farc_90_invert$conf.high['treatmentT2B']), 
data.frame(Treatment = "Rebel Culpability Treatment: FARC Zones", Method = "Select Covariates", Conf_Level = "95%", Outcome = "Confidence in 2016 Peace Agreement", Estimate = accords_farc_95_invert$coefficients['treatmentT2B'], Conf_Low = accords_farc_95_invert$conf.low['treatmentT2B'], Conf_High = accords_farc_95_invert$conf.high['treatmentT2B']), 

data.frame(Treatment = "Difference", Method = "Select Covariates", Conf_Level = "90%", Outcome = "Confidence in 2016 Peace Agreement", Estimate = accords_farc_90$coefficients['treatmentT2B:farc_presence'], Conf_Low = accords_farc_90$conf.low['treatmentT2B:farc_presence'], Conf_High = accords_farc_90$conf.high['treatmentT2B:farc_presence']), 
data.frame(Treatment = "Difference", Method = "Select Covariates", Conf_Level = "95%", Outcome = "Confidence in 2016 Peace Agreement", Estimate = accords_farc_95$coefficients['treatmentT2B:farc_presence'], Conf_Low = accords_farc_95$conf.low['treatmentT2B:farc_presence'], Conf_High = accords_farc_95$conf.high['treatmentT2B:farc_presence']), 

#ELN outcome  
  
data.frame(Treatment = "Rebel Culpability Treatment: Full Sample", Method = "Select Covariates", Conf_Level = "90%", Outcome = "Support Peace Agreement with ELN", Estimate = eln_shortmodel_90$coefficients['treatmentT2B'], Conf_Low = eln_shortmodel_90$conf.low['treatmentT2B'], Conf_High = eln_shortmodel_90$conf.high['treatmentT2B']), 
data.frame(Treatment = "Rebel Culpability Treatment: Full Sample", Method = "Select Covariates", Conf_Level = "95%", Outcome = "Support Peace Agreement with ELN", Estimate = eln_shortmodel_95$coefficients['treatmentT2B'], Conf_Low = eln_shortmodel_95$conf.low['treatmentT2B'], Conf_High = eln_shortmodel_95$conf.high['treatmentT2B']), 

data.frame(Treatment = "Rebel Culpability Treatment: Non-FARC Zones", Method = "Select Covariates", Conf_Level = "90%", Outcome = "Support Peace Agreement with ELN", Estimate = eln_farc_90$coefficients['treatmentT2B'], Conf_Low = eln_farc_90$conf.low['treatmentT2B'], Conf_High = eln_farc_90$conf.high['treatmentT2B']), 
data.frame(Treatment = "Rebel Culpability Treatment: Non-FARC Zones", Method = "Select Covariates", Conf_Level = "95%", Outcome = "Support Peace Agreement with ELN", Estimate = eln_farc_95$coefficients['treatmentT2B'], Conf_Low = eln_farc_95$conf.low['treatmentT2B'], Conf_High = eln_farc_95$conf.high['treatmentT2B']), 

data.frame(Treatment = "Rebel Culpability Treatment: FARC Zones", Method = "Select Covariates", Conf_Level = "90%", Outcome = "Support Peace Agreement with ELN", Estimate = eln_farc_90_invert$coefficients['treatmentT2B'], Conf_Low = eln_farc_90_invert$conf.low['treatmentT2B'], Conf_High = eln_farc_90_invert$conf.high['treatmentT2B']), 
data.frame(Treatment = "Rebel Culpability Treatment: FARC Zones", Method = "Select Covariates", Conf_Level = "95%", Outcome = "Support Peace Agreement with ELN", Estimate = eln_farc_95_invert$coefficients['treatmentT2B'], Conf_Low = eln_farc_95_invert$conf.low['treatmentT2B'], Conf_High = eln_farc_95_invert$conf.high['treatmentT2B']), 

data.frame(Treatment = "Difference", Method = "Select Covariates", Conf_Level = "90%", Outcome = "Support Peace Agreement with ELN", Estimate = eln_farc_90$coefficients['treatmentT2B:farc_presence'], Conf_Low = eln_farc_90$conf.low['treatmentT2B:farc_presence'], Conf_High = eln_farc_90$conf.high['treatmentT2B:farc_presence']), 
data.frame(Treatment = "Difference", Method = "Select Covariates", Conf_Level = "95%", Outcome = "Support Peace Agreement with ELN", Estimate = eln_farc_95$coefficients['treatmentT2B:farc_presence'], Conf_Low = eln_farc_95$conf.low['treatmentT2B:farc_presence'], Conf_High = eln_farc_95$conf.high['treatmentT2B:farc_presence']), 

#Dissidents outcome  
  
data.frame(Treatment = "Rebel Culpability Treatment: Full Sample", Method = "Select Covariates", Conf_Level = "90%", Outcome = "Support Peace Agreement with FARC Dissidents", Estimate = dissident_shortmodel_90$coefficients['treatmentT2B'], Conf_Low = dissident_shortmodel_90$conf.low['treatmentT2B'], Conf_High = dissident_shortmodel_90$conf.high['treatmentT2B']), 
data.frame(Treatment = "Rebel Culpability Treatment: Full Sample", Method = "Select Covariates", Conf_Level = "95%", Outcome = "Support Peace Agreement with FARC Dissidents", Estimate = dissident_shortmodel_95$coefficients['treatmentT2B'], Conf_Low = dissident_shortmodel_95$conf.low['treatmentT2B'], Conf_High = dissident_shortmodel_95$conf.high['treatmentT2B']), 

data.frame(Treatment = "Rebel Culpability Treatment: Non-FARC Zones", Method = "Select Covariates", Conf_Level = "90%", Outcome = "Support Peace Agreement with FARC Dissidents", Estimate = dissidents_farc_90$coefficients['treatmentT2B'], Conf_Low = dissidents_farc_90$conf.low['treatmentT2B'], Conf_High = dissidents_farc_90$conf.high['treatmentT2B']), 
data.frame(Treatment = "Rebel Culpability Treatment: Non-FARC Zones", Method = "Select Covariates", Conf_Level = "95%", Outcome = "Support Peace Agreement with FARC Dissidents", Estimate = dissidents_farc_95$coefficients['treatmentT2B'], Conf_Low = dissidents_farc_95$conf.low['treatmentT2B'], Conf_High = dissidents_farc_95$conf.high['treatmentT2B']), 

data.frame(Treatment = "Rebel Culpability Treatment: FARC Zones", Method = "Select Covariates", Conf_Level = "90%", Outcome = "Support Peace Agreement with FARC Dissidents", Estimate = dissidents_farc_90_invert$coefficients['treatmentT2B'], Conf_Low = dissidents_farc_90_invert$conf.low['treatmentT2B'], Conf_High = dissidents_farc_90_invert$conf.high['treatmentT2B']), 
data.frame(Treatment = "Rebel Culpability Treatment: FARC Zones", Method = "Select Covariates", Conf_Level = "95%", Outcome = "Support Peace Agreement with FARC Dissidents", Estimate = dissidents_farc_95_invert$coefficients['treatmentT2B'], Conf_Low = dissidents_farc_95_invert$conf.low['treatmentT2B'], Conf_High = dissidents_farc_95_invert$conf.high['treatmentT2B']), 

data.frame(Treatment = "Difference", Method = "Select Covariates", Conf_Level = "90%", Outcome = "Support Peace Agreement with FARC Dissidents", Estimate = dissidents_farc_90$coefficients['treatmentT2B:farc_presence'], Conf_Low = dissidents_farc_90$conf.low['treatmentT2B:farc_presence'], Conf_High = dissidents_farc_90$conf.high['treatmentT2B:farc_presence']), 
data.frame(Treatment = "Difference", Method = "Select Covariates", Conf_Level = "95%", Outcome = "Support Peace Agreement with FARC Dissidents", Estimate = dissidents_farc_95$coefficients['treatmentT2B:farc_presence'], Conf_Low = dissidents_farc_95$conf.low['treatmentT2B:farc_presence'], Conf_High = dissidents_farc_95$conf.high['treatmentT2B:farc_presence'])
)
```

#convert treatment and outcome labels to factors to control order
```{r convert characters to factors}
farc_het_effects_all$Treatment <- factor(farc_het_effects_all$Treatment, levels = c("Difference", "Rebel Culpability Treatment: Non-FARC Zones", "Rebel Culpability Treatment: FARC Zones"))

farc_het_effects_all$Outcome <- factor(farc_het_effects_all$Outcome, levels = c("Peace Agreement Attitudes Index*", "Support Peace Agreement with FARC Dissidents", "Support Peace Agreement with ELN", "Confidence in 2016 Peace Agreement"))
```

#treatment effect heterogeneity plot 
```{r plot het effects by FARC presence}
farc_het_bw <- ggplot(farc_het_effects_all %>% filter(Treatment != "Rebel Culpability Treatment: Full Sample") %>% pivot_wider(names_from = "Conf_Level", values_from = c(Estimate, Conf_Low, Conf_High)),  aes(y = Outcome, x = `Estimate_95%`, shape = Treatment)) +
        geom_vline(xintercept = 0, 
                   colour = gray(1/2), lty = 2) +
scale_shape_manual(name = "", values = c(24, 25, 23), breaks = c("Rebel Culpability Treatment: FARC Zones", "Rebel Culpability Treatment: Non-FARC Zones", "Difference"), labels = function(x) str_wrap(x, width = 12)) +
        geom_linerange(aes(y = Outcome, 
                     xmin = `Conf_Low_90%`,
                     xmax = `Conf_High_90%`),
                   lwd = 1, position=position_dodge(.45)) + 
        geom_linerange(aes(y = Outcome, 
                     xmin = `Conf_Low_95%`,
                     xmax = `Conf_High_95%`),
                   lwd = .5, position=position_dodge(.45)) +
scale_y_discrete(labels = function(x) str_wrap(x, width = 20)) +
    guides(fill = "none", shape = guide_legend(byrow = TRUE)) +
                           labs(x = "", y = "", shape = "") + 
          geom_point(aes(y = Outcome, 
                    x = `Estimate_95%`),  position=position_dodge(.45), size = 2, fill = "white") + 
                                               xlim(-2, 1) +
theme_bw() +    
  theme(legend.key.size = unit(3.25, 'lines'), theme_gray(base_size = 9))
```
